package Day019_Junit单元测试_NIO.demo3_Buffer类_缓冲区;

import java.nio.ByteBuffer;

/**
 * @author zhangyan
 * @date 2020/5/12 10:50
 */
public class Test4_容量capacity {
    public static void main(String[] args) {

        /*
            Buffer的容量(capacity)是指：Buffer所能够包含的元素的最大数量。定义了Buffer后，容量是不可变的
                public int capacity();
         */

        //创建ByteBuffer缓冲数组 容量为10
        ByteBuffer bb = ByteBuffer.allocate(10);
        System.out.println("缓冲数组容量为:" + bb.capacity()); //10

        //
        byte[] bytes = {11,22,33,44,55};
        ByteBuffer bb2 = ByteBuffer.wrap(bytes);
        System.out.println("缓冲数组容量为:" + bb2.capacity()); //5

    }
}
